package com.ratp.expertisetechnique;

import com.ratp.bean.Expertise;
import com.ratp.bean.UtilsBean;
import com.ratp.composants.CustomTextWatcher;
import com.ratp.expertisetechnique.R;

import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.widget.EditText;
import android.widget.TextView;

public class SignalementEngageantCarros extends Activity {
	private TextView editPosteCoduiteCarros1;
	private TextView editSellerieCarros;
	private TextView editEtatInterCarros;
	private TextView editParBriseCarros;
	private TextView editCarrosExt;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.signalment_engageant_carros);
		initVariables();
		initEcouteurs();
	}

	private void initVariables() {
		editPosteCoduiteCarros1 = (EditText) findViewById(R.id.editPosteCoduiteCarros1);
		editSellerieCarros = (EditText) findViewById(R.id.editSellerieCarros);
		editEtatInterCarros = (EditText) findViewById(R.id.editEtatInterCarros);
		editParBriseCarros = (EditText) findViewById(R.id.editParBriseCarros);
		editCarrosExt = (EditText) findViewById(R.id.editCarrosExt);

		Expertise expertise = UtilsBean.getExpertiseInstance();

		editPosteCoduiteCarros1.setText(expertise.getPosteConduiteEngage());
		editSellerieCarros.setText(expertise.getSellerieEngage());
		editEtatInterCarros.setText(expertise.getEtatIntEngage());
		editParBriseCarros.setText(expertise.getPareBriseEngage());
		editCarrosExt.setText(expertise.getCarrosExtEngage());
	}

	private void initEcouteurs() {



		editPosteCoduiteCarros1.addTextChangedListener(new CustomTextWatcher() {

			@Override
			public void afterTextChanged(Editable s) {
				UtilsBean.getExpertiseInstance().setPosteConduiteEngage(s.toString());
			}
		});
		editSellerieCarros.addTextChangedListener(new CustomTextWatcher() {

			@Override
			public void afterTextChanged(Editable s) {
				UtilsBean.getExpertiseInstance().setSellerieEngage(s.toString());
			}
		});
		editEtatInterCarros.addTextChangedListener(new CustomTextWatcher() {

			@Override
			public void afterTextChanged(Editable s) {
				UtilsBean.getExpertiseInstance().setEtatIntEngage(s.toString());
			}
		});
		editParBriseCarros.addTextChangedListener(new CustomTextWatcher() {

			@Override
			public void afterTextChanged(Editable s) {
				UtilsBean.getExpertiseInstance().setPareBriseEngage(s.toString());
			}
		});
		editCarrosExt.addTextChangedListener(new CustomTextWatcher() {

			@Override
			public void afterTextChanged(Editable s) {
				UtilsBean.getExpertiseInstance().setCarrosExtEngage(s.toString());
			}
		});
	}
}
